<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Function template import_class</title>
<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
<link rel="up" href="../../boost_dll/reference.html#doxygen.shared_library_refcountable_reference.import__class_8hpp" title="Header &lt;boost/dll/import_class.hpp&gt;">
<link rel="prev" href="classboost_1_1dll_1_1experimental_1_1imported__class.html" title="Class template imported_class">
<link rel="next" href="import__mangled_8hpp_1a5045a8a4b95fdf8fb85a993c5eb87113.html" title="Function template import_mangled">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td>
<td align="center"><a href="../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="classboost_1_1dll_1_1experimental_1_1imported__class.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../boost_dll/reference.html#doxygen.shared_library_refcountable_reference.import__class_8hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="import__mangled_8hpp_1a5045a8a4b95fdf8fb85a993c5eb87113.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="refentry">
<a name="doxygen.shared_library_refcountable_reference.import__class_8hpp_1a430699dfbe70d95b10f3d968268c7045"></a><div class="titlepage"></div>
<div class="refnamediv">
<h2><span class="refentrytitle">Function template import_class</span></h2>
<p>boost::dll::experimental::import_class</p>
</div>
<h2 class="refsynopsisdiv-title">Synopsis</h2>
<div class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="../../boost_dll/reference.html#doxygen.shared_library_refcountable_reference.import__class_8hpp" title="Header &lt;boost/dll/import_class.hpp&gt;">boost/dll/import_class.hpp</a>&gt;

</span>
<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">typename</span> <span class="special">...</span> Args<span class="special">&gt;</span> 
  <a class="link" href="classboost_1_1dll_1_1experimental_1_1imported__class.html" title="Class template imported_class">imported_class</a><span class="special">&lt;</span> <span class="identifier">T</span> <span class="special">&gt;</span> 
  <span class="identifier">import_class</span><span class="special">(</span><span class="identifier">smart_library</span> lib<span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> size<span class="special">,</span> <span class="identifier">Args</span><span class="special">...</span> args<span class="special">)</span><span class="special">;</span></pre></div>
<div class="refsect1">
<a name="id-1.3.12.8.3.3.6.4"></a><h2>Description</h2>
<p>Returns an instance of <a class="link" href="classboost_1_1dll_1_1experimental_1_1imported__class.html" title="Class template imported_class">imported_class</a> which allows to call or import more functions. It takes a copy of the smart_libray, so no added type_aliases will be visible, for the object.</p>
<p>Few compilers do implement an allocating constructor, which allows the construction of the class without knowing the size. That is not portable, so the actual size of the class shall always be provided.</p>
<p><span class="bold"><strong>Example:</strong></span> </p>
<pre class="programlisting"><span class="keyword">auto</span> <span class="identifier">import_class</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">type_alias</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">&amp;</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">&gt;</span><span class="special">(</span><span class="identifier">lib</span><span class="special">,</span> <span class="string">"class_name"</span><span class="special">,</span> <span class="number">20</span><span class="special">,</span> <span class="string">"param1"</span><span class="special">,</span> <span class="number">42</span><span class="special">)</span><span class="special">;</span>
</pre>
<p>In this example we construct an instance of the class "class_name" with the size 20, which has "type_alias" as an alias, through a constructor which takes a const-ref of std::string and an std::size_t parameter.</p>
<p>



xmlonly &lt;link linkend='boost.dll.fs.system_error'&gt;boost::dll::fs::system_error&lt;/link&gt; if symbol does not exist or if the DLL/DSO was not loaded. Overload that accepts path also throws std::bad_alloc in case of insufficient memory. </p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term">Parameters:</span></p></td>
<td><div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><code class="computeroutput">lib</code></span></p></td>
<td><p>Path to shared library or shared library to load function from. </p></td>
</tr></tbody>
</table></div></td>
</tr>
<tr>
<td><p><span class="term">Template Parameters:</span></p></td>
<td><div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><code class="computeroutput">T</code></span></p></td>
<td><p>Class type or alias </p></td>
</tr>
<tr>
<td><p><span class="term"><code class="computeroutput">Args</code></span></p></td>
<td><p>Constructor argument list. </p></td>
</tr>
</tbody>
</table></div></td>
</tr>
<tr>
<td><p><span class="term">Returns:</span></p></td>
<td><p>class object.</p></td>
</tr>
<tr>
<td><p><span class="term">Throws:</span></p></td>
<td> </td>
</tr>
</tbody>
</table></div>
</div>
</div>
<div class="copyright-footer">Copyright © 2014 Renato Tegon Forti, Antony Polukhin<br>Copyright © 2015 Antony Polukhin<br>Copyright © 2016 Antony Polukhin, Klemens Morgenstern<br>Copyright © 2017-2025 Antony
      Polukhin<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
      </p>
</div>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="classboost_1_1dll_1_1experimental_1_1imported__class.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../boost_dll/reference.html#doxygen.shared_library_refcountable_reference.import__class_8hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="import__mangled_8hpp_1a5045a8a4b95fdf8fb85a993c5eb87113.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
